<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/6/29 0029
  Time: 15:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <meta charset="utf-8">
    <title>赛事星登录</title>
    <link href="https://saishi.cnki.net/resource/css/CSS-reset.css?v=1792169.38" rel="stylesheet"/>
    <link href="https://saishi.cnki.net/resource/css/question/jn-question.css?v=1792169.38" rel="stylesheet"/>
    <link href="https://saishi.cnki.net/resource/css/question/login.css?v=1792169.38" rel="stylesheet"/>

    <script src="https://saishi.cnki.net/resource/js/webConfig.js?v=1792169.38"></script>
    <script src="https://saishi.cnki.net/resource/js/jquery-1.8.2.min.js"></script>
    <script src="https://saishi.cnki.net/resource/js/jquery.util.js"></script>
    <script src="https://saishi.cnki.net/resource/js/placeholder.js"></script>
    <script src="https://saishi.cnki.net/resource/js/header.js"></script>
    <script src="https://saishi.cnki.net/resource/js/layer/layer.js"></script>
    <script src="https://saishi.cnki.net/resource/js/jsencrypt.min.js?v=1792169.38"></script>

</head>

<body>
<div class="g-lg-hd">
    <a href="#" class="u-logo"></a>
</div>
<div class="g-lg-bd">
    <div class="m-lg-box clearfix">
        <div class="banner"><img src="https://saishi.cnki.net/resource/images/background/loging-banner.jpg" width="436" height="541"></div>
        <div class="login-main">
            <ul class="login-top clearfix hd">
                <li class="on"><a href="javascript:void(0)" id="id0" onclick="showTab(0)" class="person">个人用户登录</a></li>
            </ul>
            <div class="bd">
                <div id="tab0">

                    <form  action="/Eventstar/login/denglu" method="post">
                    <ul class="login-person-body">
                        <div class="login-info-height"></div>
                        <div class="login-line login-line-user">

                            <input type="text" name="user-name"  value="" placeholder="用户名">
                        </div>
                        <div class="login-line login-line-pwd">
                            <input type="password" name="password"  value=""  placeholder="密码">
                        </div>
                        <div class="login-line login-line-yanzheng clearfix">
                            <input type="text" tabindex="3" name="validCode" maxlength="4" placeholder="验证码">
                            <div class="img-yanzheng"><img id="yzm0" name="yzm"  width="63"  height="36"></div>
                            <div class="yanzheng-info">换一个</div>
                        </div>
<%--                        <div class="login-button"><a href="/student/add" class="u-btn-login" >登 录</a></div>--%>
                        <input type="submit" href="javascript:;"  class="u-btn-login"  value="登录">

                        <div class="clearfix">
                            <div class="fast-login"><span>还没有账号？</span><a href="register.jsp"><span class="register">快速注册</span></a></div>
                        </div>
                    </ul>
                    </form>
                </div>
                <input id="userType" type="hidden" name="userType" value="1" />
                <div id="tab1" style="display:none;">

                    <ul class="login-person-body">
                        <div class="login-info-height"></div>
                        <div class="login-line login-line-user">
                            <input type="text" name="user-name" maxlength="40" tabindex="6" value="" size="30" placeholder="用户名">
                        </div>
                        <div class="login-line login-line-pwd">
                            <input type="password" name="password" tabindex="7" maxlength="20" size="30" value="" placeholder="密码">
                        </div>
                        <div class="login-line login-line-yanzheng clearfix">
                            <input type="text" tabindex="8" name="validCode" maxlength="4" placeholder="验证码">
                            <div class="img-yanzheng"><img id="yzm" width="63" height="36"></div>
                            <div class="yanzheng-info">换一个</div>
                        </div>
                        <div class="login-button"><a href="javascript:;" class="u-btn-login">登 录</a></div>
                        <div class="clearfix">
                            <div class="fast-login"><span>还没有账号？</span><a href="register.jsp"><span class="register">快速注册</span></a></div>
                        </div>
                    </ul>
                </div>
            </div>
        </div>
    </div>

    <div class="g-footer clearfix">
        <div class="g-footer-top-line">《中国学术期刊(光盘版)》电子杂志社有限公司 版权所有</div>
        <div class="g-footer-top-line">京ICP证040431号 网络出版服务许可证 (总)网出证(京)字第271号 京公网安备 11010802020460 号</div>


    </div>
</div>

<input type="hidden" id="hUrl" name="hUrl" value="https://saishi.cnki.net/" />


<input type="hidden" id="hLoginUI" name="hLoginUI" value="1" />

<script type="text/javascript">
    var jsPublicKey = "-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8iKgnXm7hTxEr9FcZtBk/xbL8JwSeGpgpGMdd7TgBIARcWXhYeGRP428QYb8//Buls3ZLJAbc4Z8HxFP5yvVMksQEBkR5NyN2Jx3i83jUDX/STLy9ZhCBskNBt1zqtTRw4eEjvmsP5iZ4PyQUXUttyY2Mbjb9AZl87lTlrDCRQwIDAQAB-----END PUBLIC KEY-----";

    $(document).ready(function () {
        if ($("#userType").val() == "2") {
            showTab(1);
        }
        //setTimeout("switchImage()", 2500)
        switchImage();
        $(".login-info-height").hide();//隐藏错误提示行
    });

    //切换验证码
    function switchImage() {

        var vlocation = "loginperson";//个人
        var idx = 0;
        if ($("#userType").val() == "2") {
            vlocation = "loginenterprise"
            idx = 1;
        }
        //使用这种原生的js，为验证码图片标签赋值比jquery靠谱。
        try {
            document.getElementById("yzm" + idx).src = "https://saishi.cnki.net/passport/api/Captcha/get?w=63&h=36&n=4&vloca=" + vlocation + "&" + Math.random();

        } catch (e) {
            setTimeout("switchImage()", 1000)
            alert("验证码报错啦！！！");
        }
    }


    //点击换一换，获取新验证码
    $(".yanzheng-info").click(switchImage);

    $(".login-line input[type=text],.login-line input[type=password]").keyup(function () {
        var userType = $("#userType").val();
        var index = parseInt(userType) - 1
        try {
            var event = window.event || arguments.callee.caller.arguments[0];
            if (event.keyCode == 13) {
                $(".u-btn-login").eq(index).click();
            }
        } catch (e) {
            alert("出错：" + e);
        }

    });

    var indexLayer = 0;
    //登录提交
    $(".u-btn-login").click(function () {


        /*
        //校验用户名密码的长度

        if (password.length < 6 || password.length > 20) {
            errorMessage.addClass('login-info').html("密码请使用6-20位字符！").show();
            $(".password").eq(index).addClass("alert-border");
            return;
        }


        //校验用户名密码是否包含非法字符
        if (IsIllegalChar(userName)) {
            errorMessage.addClass('login-info').html("用户名包含非法字符，不允许登录！").show();
            $(".user-name").eq(index).addClass("alert-border");
            return;
        }
        errorMessage.hide();


        if (IsIllegalChar(password)) {
            errorMessage.addClass('login-info').html("密码包含非法字符，不允许登录！").show();
            $(".password").eq(index).addClass("alert-border");
            return;
        }
        errorMessage.hide();

        //校验用户名必须在合法的字符范围内


        //用户名不能为空
        if (!$.trim(userName)) {
            errorMessage.addClass('login-info').html("用户名不能为空！").show();
            $(".user-name").eq(index).addClass("alert-border");
            return;
        }
        else {
            $(".user-name").eq(index).removeClass("alert-border");
        }
        errorMessage.hide();
        //密码不能为空
        if (!$.trim(password)) {
            errorMessage.addClass('login-info').html("密码不能为空！").show();
            $(".password").eq(index).addClass("alert-border");
            return;
        }
        else {
            $(".password").eq(index).removeClass("alert-border");
        }
        */

        if (!$.trim(validCode) || validCode == "验证码") {
            errorMessage.addClass('login-info').html("验证码不能为空！").show();
            return;
        }
        errorMessage.hide();
        errorMessage.removeClass("login-info").html("");

        var encrypt = new JSEncrypt();
        encrypt.setPublicKey(jsPublicKey);


        indexLayer = layer.load(2, { shade: [0.6, '#000'] }); //换了种风格


    });

    //是否包含非法字符
    function IsIllegalChar(inputValue) {
        var bHaveBadChar = false;
        if (inputValue.indexOf('<') >= 0) {
            bHaveBadChar = true;
        }

        if (inputValue.indexOf('</') >= 0) {
            bHaveBadChar = true;
        }
        if (inputValue.indexOf(' ') >= 0 || inputValue.indexOf('　') >= 0) {
            bHaveBadChar = true;
        }
        if (/[#\$%\^&\*<>/]+/g.test(inputValue)) {
            bHaveBadChar = true;
        }
        return bHaveBadChar;
    }


    ///验证结果
    function ValidResult(bpass, message) {
        this.valiPass = bpass;//bool
        this.message = message;
    }

    //验证用户名
    function ValidateUserName(UserNameVal) {
        var bPassValidate = false;
        var msg = "";
        var userName = UserNameVal;
        if (userName.isNullOrWhiteSpace()) {
            msg = "用户名不能为空！";
        }
        else {
            bPassValidate = true;
            msg = "";
        }
        return new ValidResult(bPassValidate, msg);
    }

    //验证密码
    function ValidatePassword(passwordVal) {
        var bPassValidate = false;
        var msg = "";
        var password = passwordVal;
        if (password.isNullOrWhiteSpace()) {
            msg = "密码不能为空！";
        }
        else if (password.length <= 6 || password.length > 20) {
            msg = "密码请使用6-20位字符！";
        }
        else {
            msg = "";
            bPassValidate = true;
        }
        return new ValidResult(bPassValidate, msg);
    }

</script>
</body>
</html>
